package com.ayu.shortlink.project.schedule;

import com.ayu.shortlink.project.common.cache.CaffeineCacheFactory;
import com.ayu.shortlink.project.common.cache.CommonCacheService;
import org.springframework.stereotype.Component;

import static com.ayu.shortlink.project.common.constant.ShortLinkConstant.SHORT_LINK_GOTO_TOKEN_KEY;

/**
 * 定时补充令牌桶
 */
@Component
@Deprecated
public class ScheduleAddTokenTask {

    //每5秒执行一次 补充令牌的操作
    //@Scheduled(cron="0/5 * *  * * ? ")
    public void execute(){
        CommonCacheService<String, Integer> tokenBucketCache = CaffeineCacheFactory.getTokenBucketCache();

        // 放5000个令牌
        tokenBucketCache.put(SHORT_LINK_GOTO_TOKEN_KEY,5000);
    }
}
